#ifndef _FML_OTA_H_
#define _FML_OTA_H_

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "hal_flash.h"

typedef struct _OTA_INFO
{
    bool app_update_flag;
    uint8_t app_version[10];
    uint8_t app_md5[32+1];
    uint32_t app_size;
    uint8_t json_data_md5[32+1];
    uint32_t json_data_size;
}OTA_INFO;

extern OTA_INFO g_ota_info;

int32_t fml_ota_init(void);
int32_t fml_ota_flash_erase(uint32_t erase_addr, uint32_t size);
int32_t fml_ota_flash_read(uint8_t *p_data, uint32_t read_addr, uint32_t size);
int32_t fml_ota_flash_write(uint8_t *p_data, uint32_t write_addr, uint32_t size);
int32_t fml_ota_app_md5_calc(uint32_t addr, int32_t len, uint8_t *md5_out);

#endif
